<template>
  <div>
    <!-- 搜索栏 -->
    <el-form :inline="true" :model="formInline" class="search-container">
      <el-form-item label="搜索：" class="search-label">
        <el-input
          v-model="formInline.storeName"
          placeholder="请输入店铺名称"
          prefix-icon="el-icon-search"
          class="search-input"
        ></el-input>
      </el-form-item>

      <el-form-item class="btn-group">
        <el-upload
          class="avatar-uploader"
          :action="uploadPicUrl"
          :show-file-list="false"
          :on-success="handleAvatarSuccess1"
          :before-upload="beforeAvatarUpload"
        >
          <el-button
            type="warning"
            icon="el-icon-camera"
            class="verify-btn"
          >店铺核验</el-button>
        </el-upload>
      </el-form-item>

      <el-form-item class="btn-group">
        <el-button
          type="primary"
          icon="el-icon-search"
          class="search-btn"
          @click="getData"
        >搜索</el-button>
      </el-form-item>

      <el-form-item class="btn-group">
        <el-button
          type="success"
          icon="el-icon-plus"
          class="add-btn"
          @click="handleAdd"
        >添加</el-button>
      </el-form-item>
    </el-form>


    <!--列表-->
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border
              element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column  align="center"  sortable prop="storeName" label="店铺名称"></el-table-column>
      <el-table-column  align="center"  sortable prop="storeType" :formatter="formatStoreType" label="店铺类型"></el-table-column>
      <el-table-column  align="center"  sortable prop="storeScale" :formatter="formatStoreScale" label="店铺规模"></el-table-column>
      <el-table-column  align="center"  sortable prop="address" label="店铺地址"></el-table-column>
      <el-table-column  align="center"  sortable prop="business" label="业务范围"></el-table-column>
<!--      <el-table-column  align="center"  sortable prop="remark" label="店铺简介" :formatter="formatRemark"></el-table-column>-->
<!--      <el-table-column  align="center"  sortable prop="email" label="邮箱"></el-table-column>-->
      <el-table-column  align="center"  sortable prop="phoneNumber" label="联系方式"></el-table-column>
<!--      <el-table-column  align="center"  sortable prop="area" label="店铺面积m^2"></el-table-column>-->
      <el-table-column  align="center"  sortable prop="userName" label="店铺经营者"></el-table-column>
      <el-table-column  align="center"  sortable prop="createTime" label="登记时间"></el-table-column>
      <el-table-column align="center" sortable prop="approvalStatus" label="审核状态">
        <template slot-scope="scope">
          <el-button
            size="mini"
            :type="getStatusType(scope.row.approvalStatus)"
            :class="getStatusClass(scope.row.approvalStatus)"
            disabled
          >
            {{ getStatusText(scope.row.approvalStatus) }}
          </el-button>
        </template>
      </el-table-column>

<!--      <el-table-column  align="center"  sortable prop="approvalUserName" label="审批人"></el-table-column>-->
      <el-table-column sortable prop="approvalTime" label="审批时间"></el-table-column>
      <el-table-column align="center" sortable prop="approvalRemark" :formatter="formatApprovalRemark"
                       label="审批意见"></el-table-column>
      <el-table-column align="center" label="操作" width="250px">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="success" v-if="scope.row.approvalStatus == '1' && userType == '1'"
                     @click="approval(scope.$index, scope.row)">审核
          </el-button>
          <el-button size="mini" type="danger" @click="handleDel(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>

    <!-- 编辑界面 -->
    <el-dialog :title="title" :visible.sync="editFormVisible" width="50%" @click="closeDialog">
      <el-form label-width="120px" :model="editForm" :rules="rules" ref="editForm">
        <el-form-item label="店铺图片" prop="imgPath">
          <el-upload class="avatar-uploader" :action="uploadFileUrl" :show-file-list="false"
                     :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
            <img v-if="editForm.imgPath" :src="this.showUrl+editForm.imgPath" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>
        <el-form-item label="店铺名称" prop="storeName">
          <el-input v-model="editForm.storeName"></el-input>
        </el-form-item>
        <el-form-item label="店铺类型" prop="storeType">
          <el-select v-model="editForm.storeType" placeholder="请选择店铺类型">
            <el-option v-for="item in storeTypeList" :key="item.code" :label="item.name" :value="item.code"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="店铺规模" prop="storeScale">
          <el-select v-model="editForm.storeScale" placeholder="请选择店铺规模">
            <el-option v-for="item in storeScaleList" :key="item.code" :label="item.name"
                       :value="item.code"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="业务范围" prop="business">
          <el-input v-model="editForm.business"></el-input>
        </el-form-item>
        <el-form-item label="店铺简介" prop="remark">
          <el-input v-model="editForm.remark" type="textarea" rows="3"></el-input>
        </el-form-item>
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="editForm.email"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="phoneNumber">
          <el-input v-model="editForm.phoneNumber"></el-input>
        </el-form-item>
        <el-form-item label="店铺面积" prop="area">
          <el-input v-model="editForm.area"></el-input>
        </el-form-item>
<!--        <el-form-item label="所属省份" prop="provinceId">-->
<!--          &lt;!&ndash;          <el-select v-model="editForm.provinceId" placeholder="请选择所属省份">&ndash;&gt;-->
<!--          &lt;!&ndash;            <el-option v-for="item in provinceList" :key="item.code" :label="item.name" :value="item.code"></el-option>&ndash;&gt;-->
<!--          &lt;!&ndash;          </el-select>&ndash;&gt;-->
<!--          <el-autocomplete v-model="editForm.provinceName" style="width:100%;" :fetch-suggestions="queryProvince"-->
<!--                           @select="handleSelectProvince"></el-autocomplete>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="所属城市" prop="cityId">-->
<!--          &lt;!&ndash;          <el-select v-model="editForm.cityId" placeholder="请选择所属城市">&ndash;&gt;-->
<!--          &lt;!&ndash;            <el-option v-for="item in cityList" :key="item.code" :label="item.name" :value="item.code"></el-option>&ndash;&gt;-->
<!--          &lt;!&ndash;          </el-select>&ndash;&gt;-->
<!--          <el-autocomplete v-model="editForm.cityName" style="width:100%;" :fetch-suggestions="queryCity"-->
<!--                           @select="handleSelectCity"></el-autocomplete>-->
<!--        </el-form-item>-->
        <el-form-item label="所属区县" prop="districtId">
          <!--          <el-select v-model="editForm.districtId" placeholder="请选择所属区县">-->
          <!--            <el-option v-for="item in districtList" :key="item.code" :label="item.name" :value="item.code"></el-option>-->
          <!--          </el-select>-->
          <el-autocomplete v-model="editForm.districtName" style="width:100%;" :fetch-suggestions="queryDistrict"
                           @select="handleSelectDistrict"></el-autocomplete>
        </el-form-item>
        <el-form-item label="所属街道" prop="streetId">
          <!--          <el-select v-model="editForm.streetId" placeholder="请选择所属区县">-->
          <!--            <el-option v-for="item in streetList" :key="item.code" :label="item.name" :value="item.code"></el-option>-->
          <!--          </el-select>-->
          <el-autocomplete v-model="editForm.streetName" style="width:100%;" :fetch-suggestions="queryStreet"
                           @select="handleSelectStreet"></el-autocomplete>
        </el-form-item>
        <el-form-item label="店铺地址" prop="address">
          <el-input v-model="editForm.address"></el-input>
        </el-form-item>
        <!--        <el-form-item label="添加配方材料">-->
        <!--          <el-button type="success" @click="appendMaterial()">添加配方材料</el-button>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="菜品配方" v-for="(item,index) in editForm.foodFormulaList" :key="item.key">-->
        <!--          <el-autocomplete v-model="editForm.foodFormulaList[index].materialName" :fetch-suggestions="querySearchAsync"-->
        <!--                           placeholder="请输入内容" @select="((item)=>{handleSelect(item, index)})"></el-autocomplete>-->
        <!--          数量：-->
        <!--          <el-input v-model="editForm.foodFormulaList[index].amount" style="width:50px"></el-input>-->
        <!--          <el-button @click="deleteAuto(index)">删除配方材料</el-button>-->
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="submitForm('editForm')">提交
        </el-button>
      </div>
    </el-dialog>

    <!-- 审批界面 -->
    <el-dialog :title="title" :visible.sync="editFormVisibleApproval" width="50%" @click="closeDialogApproval">
      <el-form label-width="120px" :model="editForm" :rules="rulesApproval" ref="editForm">
        <el-form-item label="店铺名称" prop="storeName">
          {{ editForm.storeName }}
        </el-form-item>
        <el-form-item label="店铺类型" prop="storeType">
          {{
            editForm.storeType == '1' ? "服饰" :
              editForm.storeType == "2" ? "家居" :
                editForm.storeType == "3" ? "数码" :
                  editForm.storeType == "4" ? "美妆" :
                    editForm.storeType == "5" ? "餐饮" :
                      editForm.storeType == "6" ? "其他" :
                        "未知"
          }}
        </el-form-item>
        <el-form-item label="店铺规模" prop="storeScale">
          {{
            editForm.storeScale == '1' ? "小型店铺" :
              editForm.storeScale == "2" ? "中型店铺" :
                editForm.storeScale == "3" ? "大型店铺" :
                  "未知"
          }}
        </el-form-item>
        <el-form-item label="业务范围" prop="business">
          {{ editForm.business }}
        </el-form-item>
        <el-form-item label="店铺简介" prop="remark">
          {{ editForm.remark }}
        </el-form-item>
        <el-form-item label="业务范围" prop="email">
          {{ editForm.email }}
        </el-form-item>
        <el-form-item label="业务范围" prop="phoneNumber">
          {{ editForm.phoneNumber }}
        </el-form-item>
        <el-form-item label="店铺面积" prop="area">
          {{ editForm.area }}
        </el-form-item>
<!--        <el-form-item label="所属省份" prop="provinceId">-->
<!--          {{ editForm.provinceName }}-->
<!--        </el-form-item>-->
<!--        <el-form-item label="所属城市" prop="cityId">-->
<!--          {{ editForm.cityName }}-->
<!--        </el-form-item>-->
        <el-form-item label="所属区县" prop="districtId">
          {{ editForm.districtName }}
        </el-form-item>
        <el-form-item label="所属街道" prop="streetId">
          {{ editForm.streetName }}
        </el-form-item>
        <el-form-item label="店铺地址" prop="address">
          {{ editForm.address }}
        </el-form-item>
        <el-form-item label="店铺图片" prop="imgPath">
          <!--          <el-upload class="avatar-uploader" :action="uploadFileUrl" :show-file-list="false"-->
          <!--                     :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">-->
          <img v-if="editForm.imgPath" :src="this.showUrl+editForm.imgPath" class="avatar">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          <!--          </el-upload>-->
        </el-form-item>
        <el-form-item label="审批状态" prop="approvalStatus">
          <el-radio-group v-model="editForm.approvalStatus">
            <el-radio class="radio" :label="'2'">通过</el-radio>
            <el-radio class="radio" :label="'3'">不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审批意见" prop="approvalRemark">
          <el-input v-model="editForm.approvalRemark" type="textarea" rows="3"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialogApproval">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="approvalSubmit('editForm')">提交
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '../../api/interface'
import Pagination from '../../components/Pagination'
import {queryAreaList} from "../../api/interface";

export default {
  data() {
    return {
      loading: false, //是显示加载
      editFormVisible: false, //控制编辑页面显示与隐藏
      editFormVisibleApproval: false, //控制编辑页面显示与隐藏
      addFormVisible: false,//控制添加页面显示与隐藏
      title: '',
      editForm: {},
      addForm: {},
      // rules表单验证
      rules: {
        storeName: [{required: true, message: '请输入店铺名称', trigger: 'blur'}],
        storeType: [{required: true, message: '请输入店铺类型', trigger: 'blur'}],
        storeScale: [{required: true, message: '请输入店铺规模', trigger: 'blur'}],
        provinceId: [{required: true, message: '请输入所属省份', trigger: 'blur'}],
        cityId: [{required: true, message: '请输入所属城市', trigger: 'blur'}],
        districtId: [{required: true, message: '请输入所属区县', trigger: 'blur'}],
        streetId: [{required: true, message: '请输入所属街道', trigger: 'blur'}],
        address: [{required: true, message: '请输入店铺地址', trigger: 'blur'}],
        imgPath: [{required: true, message: '请上传图片', trigger: 'blur'}],
      },
      // rules表单验证
      rulesApproval: {
        approvalStatus: [{required: true, message: '请选择审批状态', trigger: 'blur'}],
        approvalRemark: [{required: true, message: '请输入审批意见', trigger: 'blur'}],
      },
      //查询条件
      formInline: {
        page: 1, //当前页面
        limit: 10, //每页数量
        storeName: ''
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      },
      userType: "",
      userId: "",
      userName: "",
      uploadFileUrl: api.uploadFileUrl,
      uploadPicUrl: api.uploadPicUrl,
      showUrl: api.showUrl,
      tempId: 1,
      storeTypeList: [
        {code: "", name: "请选择"},
        {code: "1", name: "服饰"},
        {code: "2", name: "家居"},
        {code: "3", name: "数码"},
        {code: "4", name: "美妆"},
        {code: "5", name: "餐饮"},
        {code: "6", name: "其他"}
      ],
      storeScaleList: [
        {code: "", name: "请选择"},
        {code: "1", name: "小型店铺"},
        {code: "2", name: "中型店铺"},
        {code: "3", name: "大型店铺"}
      ],
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  /**
   * 页面初始化方法
   */
  created() {
    this.userType = localStorage.getItem("userType");
    this.userId = localStorage.getItem("userId");
    this.userName = localStorage.getItem("userName");
    console.log(this.$store.state.userInfo)
    this.getData()
  },
  methods: {
    formatStoreType: function (row, column) {
      return row.storeType == '1' ? "服饰" :
        row.storeType == "2" ? "家居" :
          row.storeType == "3" ? "数码" :
            row.storeType == "4" ? "美妆" :
              row.storeType == "5" ? "餐饮" :
                row.storeType == "6" ? "其他" :
                  "未知";
    },
    formatStoreScale: function (row, column) {
      return row.storeScale == '1' ? "小型店铺" :
        row.storeScale == "2" ? "中型店铺" :
          row.storeScale == "3" ? "大型店铺" :
            "未知";
    },
    formatApprovalStatus: function (row, column) {
      return row.approvalStatus == '1' ? "未审核" :
        row.approvalStatus == "2" ? "审核通过" :
          row.approvalStatus == "3" ? "审核驳回" :
            "未知";
    },
    // 获取状态按钮类型
    getStatusType(status) {
      const statusMap = {
        '1': 'warning',    // 未审核
        '2': 'success',    // 审核通过
        '3': 'danger'      // 审核驳回
      }
      return statusMap[status] || 'info'
    },

    // 获取状态文本
    getStatusText(status) {
      const statusMap = {
        '1': '未审核',
        '2': '审核通过',
        '3': '审核驳回'
      }
      return statusMap[status] || '未知'
    },

    // 获取状态类名
    getStatusClass(status) {
      return `status-button status-${status}`
    },
    formatApprovalRemark: function (row, column) {
      return row.approvalRemark && row.approvalRemark.length > 10 ? row.approvalRemark.substring(0, 10) + "..." : row.approvalRemark;
    },
    formatRemark: function (row, column) {
      return row.remark && row.remark.length > 10 ? row.remark.substring(0, 10) + "..." : row.remark;
    },
    // 获取列表数据
    getData() {
      this.loading = true
      let para = {
        current: this.formInline.page,
        size: this.formInline.limit,
        storeName: this.formInline.storeName
      }
      //如果不是管理员，只能看自己的店铺
      if (this.userType != '1') {
        para.userId = this.userId
      }
      api.queryStoreByPage(para).then(data => {
        this.logining = false;
        if (data.message != "success") {
          this.logining = false;
          this.$message.error(data.message)
        } else {
          this.loading = false
          this.listData = data.returnPage.records
          // this.listData.forEach(food => {
          //   food.formula = "";
          //   if (food.foodFormulaList && food.foodFormulaList.length > 0) {
          //     food.foodFormulaList.forEach(item => {
          //       food.formula += item.materialName + "数量:" + item.amount + ",";
          //     })
          //     food.formula = food.formula.substring(0, food.formula.length - 1);
          //   }
          // })
          this.pageparm.currentPage = data.returnPage.current
          this.pageparm.pageSize = data.returnPage.size
          this.pageparm.total = data.returnPage.total
        }
      }).catch(e => {
        this.logining = false;
      });
    },
    queryProvince(querystring, callback) {
      let param = {
        "level": "1",
        "name": querystring
      }
      api.queryAreaList(param).then(data => {
        if (data.message != "success") {
          this.$message.error(data.message)
          return []
        } else {
          let list = data.returnList.map(item => {
            item.value = item.name
            return item;
          });
          callback(list);
        }
      })
    },
    handleSelectProvince(item, index) {
      this.editForm.provinceId = item.code;
      this.editForm.provinceName = item.name;
    },
    queryCity(querystring, callback) {
      let param = {
        "level": "2",
        "name": querystring,
        "parentCode": this.editForm.provinceId
      }
      api.queryAreaList(param).then(data => {
        if (data.message != "success") {
          this.$message.error(data.message)
          return []
        } else {
          let list = data.returnList.map(item => {
            item.value = item.name
            return item;
          });
          callback(list);
        }
      })
    },
    handleSelectCity(item, index) {
      this.editForm.cityId = item.code;
      this.editForm.cityName = item.name;
    },
    queryDistrict(querystring, callback) {
      let param = {
        "level": "3",
        "name": querystring,
        "parentCode": "230100"
      }
      api.queryAreaList(param).then(data => {
        if (data.message != "success") {
          this.$message.error(data.message)
          return []
        } else {
          let list = data.returnList.map(item => {
            item.value = item.name
            return item;
          });
          callback(list);
        }
      })
    },
    queryStreet(querystring, callback) {
      let param = {
        "level": "4",
        "name": querystring,
        "parentCode": this.editForm.districtId
      }
      api.queryAreaList(param).then(data => {
        if (data.message != "success") {
          this.$message.error(data.message)
          return []
        } else {
          let list = data.returnList.map(item => {
            item.value = item.name
            return item;
          });
          callback(list);
        }
      })
    },
    handleSelectDistrict(item, index) {
      this.editForm.districtId = item.code;
      this.editForm.districtName = item.name;
    },
    handleSelectStreet(item, index) {
      this.editForm.streetId = item.code;
      this.editForm.streetName = item.name;
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage
      this.formInline.limit = parm.pageSize
      this.getData()
    },
    //显示添加界面
    handleAdd: function (index, row) {
      this.editFormVisible = true
      this.title = '新增'
    },
    //显示编辑界面--编辑此行信息
    handleEdit: function (index, row) {
      this.editFormVisible = true
      this.title = '编辑'
      this.editForm = Object.assign({}, row)
    },
    // 关闭编辑
    closeDialog() {
      this.editFormVisible = false
    },
    // 关闭编辑
    closeDialogApproval() {
      this.editFormVisibleApproval = false
    },
    // 编辑、增加页面保存方法
    submitForm(editData) {
      this.$refs[editData].validate(valid => {
        if (valid) {
          let para = Object.assign({}, this.editForm);
          para.userId = this.userId;
          para.userName = this.userName;
          this.loading = true;
          api.updateStore(para)
            .then(res => {
              this.loading = false;
              if (res.message == 'success') {
                this.$message({message: "提交成功", type: "success"});
                this.getData();
                this.editFormVisible = false;
              } else {
                this.$message({type: 'error', message: res.message})
              }
            })
            .catch(e => {
              // this.editFormVisible = false
              this.loading = false
            })
        } else {
          return false
        }
      })
    },
    // 审批
    approvalSubmit(editData) {
      this.$refs[editData].validate(valid => {
        if (valid) {
          let para = Object.assign({}, this.editForm);
          para.approvalTime = new Date();
          let userId = window.localStorage.getItem("userId");
          let userName = window.localStorage.getItem("userName");
          para.approvalUserId = userId;
          para.approvalUserName = userName;
          if (para.approvalStatus != '2' && para.approvalStatus != '3') {
            this.$message({type: 'error', message: "请选择审批状态"});
            return;
          }
          this.loading = true;
          api.updateStore(para)
            .then(res => {
              this.loading = false;
              if (res.message == 'success') {
                this.$message({message: "提交成功", type: "success"});
                this.getData();
                this.editFormVisibleApproval = false;
              } else {
                this.$message({type: 'error', message: res.message})
              }
            })
            .catch(e => {
              // this.editFormVisible = false
              this.loading = false
            })
        } else {
          return false
        }
      })
    },
    // 删除--此行
    handleDel(index, row) {
      this.$confirm('确定要删除吗?', '信息', {confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'})
        .then(() => {
          let para = {
            storeId: row.storeId
          }
          api.delStore(para)
            .then(res => {
              if (res.message == 'success') {
                this.$message({message: "删除成功", type: "success"});
                this.getData();
              } else {
                this.$message({type: 'error', message: res.message})
              }
            })
            .catch(e => {
              this.loading = false
            })
        });
    },
    handleAvatarSuccess(res, file) {
      this.editForm.imgPath = res.returnObj;
      this.$forceUpdate();
    },
    handleAvatarSuccess1(res, file) {
      if (res.message == 'success') {
        this.formInline.storeName = res.returnObj;
        this.getData();
      } else {
        this.$message({type: 'error', message: res.message})
      }
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传店铺图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传店铺图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
    // appendMaterial() {
    //   this.editForm.foodFormulaList.push({
    //     "key": this.tempId++
    //   });
    // },
    // deleteAuto: function (index) {
    //   this.editForm.foodFormulaList.splice(index, 1);
    // },
    // querySearchAsync(queryString, callback) {
    //   let para = {materialName: queryString};
    //   // api.queryMaterial(para).then(res => {
    //   //     for (let i of res.returnList) {
    //   //         i.value = i.materialName;
    //   //     }
    //   //     var list = res.returnList;
    //   //     callback(list);
    //   // }).catch(() => {});
    // },
    // handleSelect(item, index) {
    //   this.editForm.foodFormulaList[index].materialName = item.materialName;
    //   this.editForm.foodFormulaList[index].materialId = item.materialId;
    //   this.editForm.foodFormulaList[index].unit = item.unit;
    // },
    //显示编辑界面--编辑此行信息
    approval: function (index, row) {
      this.editFormVisibleApproval = true
      this.title = '审批'
      this.editForm = Object.assign({}, row)
    },
  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
.search-container {
  background: #f5f7fa;
  padding: 20px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.search-label {
  font-weight: bold;
  color: #333;
  font-size: 16px;
  margin-right: 10px;
}

.search-label .el-form-item__label {
  font-size: 16px;
  line-height: 40px;
}

.search-input {
  width: 300px;
}

.search-input .el-input__inner {
  height: 40px;
  font-size: 16px;
  border: 1px solid #dcdfe6;
}

.btn-group {
  margin-left: 15px;
}

/* 统一按钮样式 */
.verify-btn,
.search-btn {
  height: 40px;
  font-size: 16px;
  padding: 0 25px;
  transition: all 0.3s;
}

.verify-btn {
  background: #e6a23c;
  border-color: #e6a23c;
  color: white;
}

.verify-btn:hover {
  background: #ebb563;
  border-color: #ebb563;
  opacity: 0.9;
}

.search-btn:hover {
  opacity: 0.9;
}

/* 图标样式 */
.el-icon-picture,
.el-icon-search {
  font-size: 16px;
  margin-right: 5px;
}

/* 表单项垂直对齐 */
.el-form-item {
  margin-bottom: 0;
  vertical-align: middle;
}

.el-form-item__content {
  line-height: 40px;
}

/* 输入框placeholder样式 */
.el-input__inner::placeholder {
  font-size: 14px;
  color: #999;
}

/* 确保上传组件样式正确 */
.avatar-uploader {
  display: inline-block;
}
/* 状态按钮基础样式 */
.status-button {
  width: 80px !important;
  cursor: default !important;
}

/* 未审核状态 */
.status-1.el-button--warning {
  background-color: #ffd04b;
  border-color: #ffd04b;
  color: #fff;
}

/* 审核通过状态 */
.status-2.el-button--success {
  background-color: #67c23a;
  border-color: #67c23a;
  color: #fff;
}

/* 审核驳回状态 */
.status-3.el-button--danger {
  background-color: #f56c6c;
  border-color: #f56c6c;
  color: #fff;
}

/* 未知状态 */
.el-button--info.is-disabled {
  background-color: #909399;
  border-color: #909399;
  color: #fff;
}

/* 禁用状态下保持颜色 */
.status-button.is-disabled {
  opacity: 1 !important;
}

/* 鼠标悬停效果 */
.status-button:hover {
  opacity: 0.9;
}
</style>
